mirror of
https://github.com/godotengine/godot.git
synced 2026-03-03 20:55:48 +00:00
Add sha256_buffer() function to String
This commit is contained in:
@@ -2419,6 +2419,23 @@ Vector<uint8_t> String::md5_buffer() const {
|
||||
return ret;
|
||||
};
|
||||
|
||||
Vector<uint8_t> String::sha256_buffer() const {
|
||||
CharString cs = utf8();
|
||||
unsigned char hash[32];
|
||||
sha256_context ctx;
|
||||
sha256_init(&ctx);
|
||||
sha256_hash(&ctx, (unsigned char*)cs.ptr(), cs.length());
|
||||
sha256_done(&ctx, hash);
|
||||
|
||||
Vector<uint8_t> ret;
|
||||
ret.resize(32);
|
||||
for (int i = 0; i < 32; i++) {
|
||||
ret[i] = hash[i];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
String String::insert(int p_at_pos,String p_string) const {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user