Basics of building a blockchain using python, part 1
“Even if you are on the right track, you’ll get run over if you just sit there.” ― Will Rogers
A Blockchain is all the craze right now. With the Bitcoin price on a runaway track, everyone wants in on the bitcoin bandwagon. While buying and selling bitcoin and other cryptocurrencies is good (or bad, depending on your finances!), let us learn the basics of the technology behind these cryptocurrencies. In the process we will also attempt to come up with the building blocks of the technology starting from scratch.
Easily incorporate strong AES encryption into your programs.
“Believe in your infinite potential. Your only limitations are those you set upon yourself.” ― Roy T. Bennett, The Light in the Heart
Pycrypto is a python module that provides cryptographic services. Pycrypto is somewhat similar to JCE (Java Cryptography Extension) for Java. In our experience JCE is more extensive and complete, and the documentation for JCE is also more complete. That being said, pycrypto is a pretty good module covering many aspects of cryptography.
Secure message authentication using a MAC generated from a secret key with a password.
“There is some good in this world, and it’s worth fighting for.” ― J.R.R. Tolkien, The Two Towers
A Message Authentication Code or a MAC provides a way to guarantee that a message (a byte array) has not been modified in transit. It is similar to a message digest to calculate a hash, but uses a secret key so that only a person with the secret key can verify the authenticity of the message.
Encrypt a file using a password with strong AES security.
“My tastes are simple: I am easily satisfied with the best.”
― Winston S. Churchill
In a previous article, we have explained how to use AES for encryption and decryption. After encryption, the AES key will need to be communicated to the receiver via a secure channel for decrypting the file.
AES can be used for encrypting the file and RSA for encrypting the AES key.
“The secret of education lies in respecting the pupil.”
― Ralph Waldo Emerson
In the previous part of this article, we covered the use of RSA for file encryption and decryption in java. Using RSA directly for file encryption will not work since it can only be used with small buffer sizes. In our particular case, with an RSA key size of 2048 bits, we ran into a limitation of a maximum of 245 bytes for the data size.
Use RSA for File Encryption and Decryption in Java
“If you can’t do anything about it, laugh like hell.”
― David Cook
RSA (Rivest–Shamir–Adleman) is an asymmetric encryption algorithm widely used in public-key cryptography today. The word asymmetric denotes the use of a pair of keys for encryption – a public key and a private key. When data is encrypted by one key, it can only be decrypted using the other key. The public key is publicized and the private key is kept secret.
Let us learn how to generate some random numbers in Java. Random numbers are needed for various purposes; maybe you want to generate a password or a session identifier. Whatever the purpose may be, there are a number of issues to be aware of when generating a random number.