summaryrefslogtreecommitdiff
path: root/core/ustring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index ea9a9d903e..6788ada1bb 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -257,13 +257,10 @@ bool String::operator==(const StrRange &p_range) const {
return true;
const CharType *c_str=p_range.c_str;
-
- int l=length();
-
- const CharType *dst = p_range.c_str;
+ const CharType *dst = &operator[](0);
/* Compare char by char */
- for (int i=0;i<l;i++) {
+ for (int i=0;i<len;i++) {
if (c_str[i]!=dst[i])
return false;
@@ -2419,6 +2416,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 {
@@ -3822,7 +3836,6 @@ String String::lpad(int min_length, const String& character) const {
String String::sprintf(const Array& values, bool* error) const {
String formatted;
CharType* self = (CharType*)c_str();
- int num_items = values.size();
bool in_format = false;
int value_index = 0;
int min_chars;