locked
decrypt using SHA1 RRS feed

  • Question

  • I have SHA1 private key and public certificate and big file encrypted by this. How I can decrypt it?
    Tuesday, March 10, 2015 9:11 PM

Answers

  • Hi , 
    Per my understanding,SHA1 is not an encryption algorithm, so it is not possible to decrypt it.It is a hash (checksum.) A hash is a cryptographic one-way function that always generates a value of the same length regardless of the length of the input. So, you Can't,  this is why it is used for passwords, because you can't get the password using some reverse function on the hash value.

    A similar thread realted to yours Encryption using SHA1  
    You can refer these links for the other solution:
    Encryption/Decryption Function in .NET using the TripleDESCryptoServiceProvider Class[^]

    Simple encrypting and decrypting data in C#[^]

    Have a nice day!

    Kristin 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Kristin Xie Wednesday, March 11, 2015 9:33 AM
    • Proposed as answer by Magnus (MM8)MVP Wednesday, March 11, 2015 9:55 AM
    • Marked as answer by Kristin Xie Friday, March 20, 2015 8:37 AM
    Wednesday, March 11, 2015 9:32 AM

  • I think you are correct SHA1 is for hash, my key says RSA so my understanding is file encryption is done by RSA. So just to correct my original question I like to know option to decrypt  for RSA.

    -->Just based on your original post, you didn't mentioned encryption and decryption using the implementation of the RSA algorithm.  Now I am afraid this issue is not related to the original issue.

    Actually, each post corresponds to one issue. If you have any other issues about C#, It could be better to open up a new issue. Thanks for your effort and support.

    saying The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

    ---> Now from the error information, It means some characters are not valid in a base 64 string. Please check your encrypted file.

    In addition, about RSA encryption and decryption, here is a example uses the RSACryptoServiceProvider class to encrypt a string into an array of bytes and then decrypt the bytes back into a string.  please also refer to https://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 fore more detailed information.

    Another good sample

    http://www.c-sharpcorner.com/UploadFile/75a48f/rsa-algorithm-with-C-Sharp2/

    Best regards,

    Kristin



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Kristin Xie Wednesday, March 18, 2015 9:44 AM
    • Marked as answer by Kristin Xie Friday, March 20, 2015 8:36 AM
    Thursday, March 12, 2015 2:02 AM

All replies

  • have you tried the example shown in the below link,

    http://stackoverflow.com/questions/4097514/decrypt-with-privatekey-x-509-certificate

    Wednesday, March 11, 2015 4:40 AM
  • Hi , 
    Per my understanding,SHA1 is not an encryption algorithm, so it is not possible to decrypt it.It is a hash (checksum.) A hash is a cryptographic one-way function that always generates a value of the same length regardless of the length of the input. So, you Can't,  this is why it is used for passwords, because you can't get the password using some reverse function on the hash value.

    A similar thread realted to yours Encryption using SHA1  
    You can refer these links for the other solution:
    Encryption/Decryption Function in .NET using the TripleDESCryptoServiceProvider Class[^]

    Simple encrypting and decrypting data in C#[^]

    Have a nice day!

    Kristin 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Kristin Xie Wednesday, March 11, 2015 9:33 AM
    • Proposed as answer by Magnus (MM8)MVP Wednesday, March 11, 2015 9:55 AM
    • Marked as answer by Kristin Xie Friday, March 20, 2015 8:37 AM
    Wednesday, March 11, 2015 9:32 AM
  • I think you are correct SHA1 is for hash, my key says RSA so my understanding is file encryption is done by RSA. So just to correct my original question I like to know option to decrypt  for RSA.

    Actually I tried but it getting failed at Convert.FromBase64String(text), here text is data from my encrypted file. 

    saying The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

    Wednesday, March 11, 2015 4:16 PM

  • I think you are correct SHA1 is for hash, my key says RSA so my understanding is file encryption is done by RSA. So just to correct my original question I like to know option to decrypt  for RSA.

    -->Just based on your original post, you didn't mentioned encryption and decryption using the implementation of the RSA algorithm.  Now I am afraid this issue is not related to the original issue.

    Actually, each post corresponds to one issue. If you have any other issues about C#, It could be better to open up a new issue. Thanks for your effort and support.

    saying The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

    ---> Now from the error information, It means some characters are not valid in a base 64 string. Please check your encrypted file.

    In addition, about RSA encryption and decryption, here is a example uses the RSACryptoServiceProvider class to encrypt a string into an array of bytes and then decrypt the bytes back into a string.  please also refer to https://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 fore more detailed information.

    Another good sample

    http://www.c-sharpcorner.com/UploadFile/75a48f/rsa-algorithm-with-C-Sharp2/

    Best regards,

    Kristin



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Kristin Xie Wednesday, March 18, 2015 9:44 AM
    • Marked as answer by Kristin Xie Friday, March 20, 2015 8:36 AM
    Thursday, March 12, 2015 2:02 AM