By looking around here as well as the internet in general, I have found Bouncy Castle. I want to use Bouncy Castle (or some other freely available utility) to generate a SHA-256 Hash of a String in Java. Looking at their documentation I can't seem to find any good examples of what I want to do. Can anybody here help me out?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I suppose you are using a relatively old Java Version without SHA-256. So you must add the BouncyCastle Provider to the already provided 'Security Providers' in your java version.
This will work with "org.bouncycastle.util.encoders.Hex" following package
Its in bouncycastle jar.
Java 8: Base64 available:
You don't necessarily need the BouncyCastle library. The following code shows how to do so using the Integer.toHexString function
Special thanks to user1452273 from this post: How to hash some string with sha256 in Java?
Keep up the good work !
This is already implemented in the runtime libs.
In a JEE6+ environment one could also use JAXB DataTypeConverter: