Simple Encryption in Ruby without external gems

You could use OpenSSL::Cipher # for more info, see http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html require ‘openssl’ require ‘digest/sha1’ # create the cipher for encrypting cipher = OpenSSL::Cipher::Cipher.new(“aes-256-cbc”) cipher.encrypt # you will need to store these for later, in order to decrypt your data key = Digest::SHA1.hexdigest(“yourpass”) iv = cipher.random_iv # load them into the cipher cipher.key = key cipher.iv … Read more

Really simple encryption with C# and SymmetricAlgorithm

If you don’t want to handle keys yourself then let the operating system do it for your. E.g. use Windows Data Protection (DPAPI). You can write your own, string-based, version of System.Security.Cryptography.ProtectedData.Protect and Unprotect methods by using something like: public static string Crypt (this string text) { return Convert.ToBase64String ( ProtectedData.Protect ( Encoding.Unicode.GetBytes (text) ) … Read more

PHP AES encrypt / decrypt

Please use an existing secure PHP encryption library It’s generally a bad idea to write your own cryptography unless you have experience breaking other peoples’ cryptography implementations. None of the examples here authenticate the ciphertext, which leaves them vulnerable to bit-rewriting attacks. If you can install PECL extensions, libsodium is even better <?php // PECL … Read more

How to encrypt/decrypt data in php?

Foreword Starting with your table definition: – UserID – Fname – Lname – Email – Password – IV Here are the changes: The fields Fname, Lname and Email will be encrypted using a symmetric cipher, provided by OpenSSL, The IV field will store the initialisation vector used for encryption. The storage requirements depend on the … Read more

How do you Encrypt and Decrypt a PHP String?

Before you do anything further, seek to understand the difference between encryption and authentication, and why you probably want authenticated encryption rather than just encryption. To implement authenticated encryption, you want to Encrypt then MAC. The order of encryption and authentication is very important! One of the existing answers to this question made this mistake; … Read more

Simplest two-way encryption using PHP

Important: Unless you have a very particular use-case, do not encrypt passwords, use a password hashing algorithm instead. When someone says they encrypt their passwords in a server-side application, they’re either uninformed or they’re describing a dangerous system design. Safely storing passwords is a totally separate problem from encryption. Be informed. Design safe systems. Portable … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)