I want to return my original string from MD5, which is stored in database.
Here I have stored the password, it is- dipti and encrypted as
95e62d2c1c1cdab7efda7d2cdb64cf85
$password = md5($this->input->post('password'));
Now I want to show the original string as dipti.
MD5 is a hashing technique. You cannot decrypt it. You can compare the MD5 value with the another MD5 value to check matches (mostly in the case of password verification...)
The following site try to make the value from the MD5 value to original text
http://www.md5online.org/md5-decrypt.html
Related
In one of our signup processes, in a Ruby on Rails app, I want to send someone an email with a 6-digit numerical code that they need to copy or type into a box on the page.
How I thought I might do it is to have a string on the page, in a hidden field, say, which, on generating the email, gets combined with some secret key from our codebase, then hashed or encrypted to a series of decimal numbers. I then take the last six of these and put them in the email.
When the form is submitted, with the original string, and the 6 digits the user has typed in, I can repeat the process on the string and test that it produces the same six digits as the user entered.
The question is: how do I hash/encrypt a string to get a series of decimal numbers? The original string can be anything (including a different set of decimal numbers), it just needs to be something that is randomly generated really.
Note: Do not use this as a security measure. You've stated that you intend to use this only as a kind of diy captcha system, and this answer is provided in that context.
OpenSSL provides good hash functions. Once you have the hash in hex the to_i method takes a base argument, so converting to decimal is simple. Then back to a string because that makes it easier to get the last characters.
require 'openssl'
hash = OpenSSL::Digest::SHA256.hexdigest('user#example.com' + Random.new_seed.to_s)
message = hash.to_i(16).to_s.chars.last(6).join
You could then store any part of this along with an expiration time.
After downloaded file from internet, we always use MD5 or SHA-1 to check integrity of that file. I have a little concern that follow RFC1312 MD5 use an input is "b-bit message" to hash and give the result is 128 bits out put. But if I give MD5 algorithm a file, not a string, what "b-bit message" did MD5 use to hash?
Thanks for reading my topic.
A webapp I created supports offline storage... but it very quickly becomes maxed out when users add 10-13 photos. The photos are stored as super long base64 encoded strings.... but can they be stored as sha1?
Hashing is different of Encryption/Encoding
Base64 is an Encoding Method witch means that you can Decode without the need of a key
SHA1 is an Hashing Method witch means that it will generate a string depending of the content to be hashed, it can not be decoded or decrypted
Then you have Encryption (for example AES) that you Encrypt the content with that algorithm and with a key, to decrypt the data you need the encryption method and the key, without one of these elements you can not decrypt the data.
If you store the photos as SHA1 it will save a lot of space, but you can never retrieve them because all you have is a string with the hashed content.
I don't think there is a way to escape the space occupied by the photos, you might try saving to a byte array but I think the occupied space is the same because you need all the photo information to be available again
Examples (Encoding, Hashing, Encrypting word "teste")
Base64 Encoding: dGVzdGU=Website to test the encoding: https://www.base64encode.org/
SHA1 Hashing: 2e6f9b0d5885b6010f9167787445617f553a735f
Website to test the hashing to SHA1: http://www.sha1hash.com/
AES Encryption generates a byte array.Base64 equivalent to the AES Byte Array: SUpXhKOAO1pQdXD2igf0cw==Key used: key_to_encrypt_decryptSize: 128 BitWebsite to test the encryption of AES: http://aesencryption.net/
I get that the encryption class produces different output each time the same word/string is encrypted, for example, $this->encrypt->encode("word") ran five times would produce five different encrypted strings.
How can I reference the encrypted string in a DB query if each time I call $this->encrypt->encode("word") gives me something different?
Asked in a different way, is there something I can encrypt with that doesn't have a random value so that each time I encrypt I get the same output for the same input?
Base64 encoding is not encryption (referring to your own answer). I have not used codeigniter, but I notice on its doc pages that it allows:
$this->encrypt->set_mode();
You could encrypt with ECB mode (MCRYPT_MODE_ECB) for deterministic encryption where the same data always encrypts to the same ciphertext. This way, you encrypt your search string, and it will match the encrypted data in the database.
This is considered a weakness of ECB mode, but in this case, the deterministic behavior may be what you want.
I think base64_encode($str) is what I'm looking for.
this code works only on php 5.5 or higher
echo password_hash(variable, PASSWORD_DEFAULT);
The first parameter is the password string that needs to be hashed and the second parameter specifies the algorithm that should be used for generating the hash.
The default algorithm is currently bcrypt, but a stronger algorithm may be added as the default later at some point in the future and may generate a larger string. If you are using PASSWORD_DEFAULT in your projects, be sure to store the hash in a column that’s capacity is beyond 60 characters. Setting the column size to 255 might be a good choice. You could also use PASSWORD_BCRYPT as the second parameter. In this case the result will always be 60 characters long.
and to check the password hash here is the syntax
<?php
if (password_verify($oldpassword, $hash)) {
// Success!
// the first parameter is your password that's not yet encrypted, the secode is your password encrypted
}
else {
// Invalid password
}
Can someone explain me when to use String Value or Binary Value in windows registry? Is there any security concerns also attached with these or not ?
I want to store date in encrypted format
You must use the binary format. Encrypted data cannot be stored in a string. It will randomly get corrupted when the string is normalized, not every byte value is a valid Unicode codepoint. If you absolutely want a string then you have to encode the data, Convert.ToBase64String().