Closed eamanu closed 7 years ago
Are you sure you're doing the encryption correctly? How are you encrypting the tokens?
I used this code to encrypt:
from encryption import decrypt
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.serialization import load_pem_public_key
pkey = load_pem_public_key(open("server/pubkey.txt", "rb").read(), default_backend())
# defines the tokens and keys
consumer_key = b'1234'
consumer_secret = b'1234'
access_token = b'2134'
access_secret = b'12345'
def encryp(key):
encrypted = pkey.encrypt(key, padding.OAEP(
padding.MGF1(hashes.SHA1()),
hashes.SHA1(),
None
))
return encrypted
f = open("twitter_keys.secret/consumer_key.secret", "wb")
f.write(encryp(consumer_key))
f.close()
f = open("twitter_keys.secret/consumer_secret.secret", "wb")
f.write(encryp(consumer_secret))
f.close()
f = open("twitter_keys.secret/access_token.secret", "wb")
f.write(encryp(access_token))
f.close()
f = open("twitter_keys.secret/access_secret.secret", "wb")
f.write(encryp(access_secret))
f.close()
And then to read the keys I used this:
PATH = 'twitter_keys.secret/'
l_files = ['consumer_key', 'consumer_secret', 'access_token', 'access_secret']
for k in l_files:
f = open(PATH + k + ".secret", 'rb')
key = f.read()
if (k == 'consumer_key'):
consumer_key = decrypt(key)
if (k == 'consumer_secret'):
consumer_secret = decrypt(key)
if (k == 'access_token'):
access_token = decrypt(key)
if (k == 'access_secret'):
access_secret = decrypt(key)
f.close()
If I run in the console, work ok. But when I run with docker: ./run.sh
I have errors
If I run in the console, work ok. But when I run with docker: ./run.sh I have errors
Are you sure the key is the same for both of them?
Yes. Is the same code .
The same code, or the same key? The key is randomly generated, so it won't be the same in docker by default, even if the code is the same. Copy /etc/privkey
from your machine into the docker container.
I am using the same public key
to encrypt my twitters keys.
I encrypt the twtitter keys with encryp(key)
. And then decrypt with decrypt(key)
How do yo do to encrypt yours (for example, twitter) keys and then upload to the github?
@phil-r Do you know about the encrypt?
I am working in #443 and I need encrypt the tokens.
I can encrypt correctly but when I decrypt it raise this message