-
-
Save failshell/b93167694187de7ea405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def encrypt(plaintext, key) | |
cipher = OpenSSL::Cipher::AES256.new(:CBC) | |
cipher.encrypt | |
cipher.key = File.read(key) | |
iv = cipher.random_iv | |
encrypted = cipher.update(plaintext) + cipher.final | |
puts Base64.encode64("#{Base64.encode64(encrypted)},#{Base64.encode64(iv)}") | |
puts Base64.encode64("#{Base64.encode64(encrypted)},#{Base64.encode64(iv)}").inspect | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[failshell@manticore]:titan git:(master) ✗ $ ./bin/titan -k key -e 'some super secret' | |
OTZGdWtzM01id3pndEJzVlZRTjBKckFsclhzZm9TVElaRHJWc0s4Vm5Udz0K | |
LHdPdXpoMEdCM3ZvbU45N1pQdGdoYXc9PQo= | |
"OTZGdWtzM01id3pndEJzVlZRTjBKckFsclhzZm9TVElaRHJWc0s4Vm5Udz0K\nLHdPdXpoMEdCM3ZvbU45N1pQdGdoYXc9PQo=\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment