瀏覽代碼

fixed to Base64 encoding

Yannick Dominguez 10 年之前
父節點
當前提交
44be648c4a
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      std/haxe/crypto/Base64.hx

+ 6 - 1
std/haxe/crypto/Base64.hx

@@ -32,8 +32,13 @@ class Base64 {
 	public static function encode( bytes : haxe.io.Bytes, complement = true ) : String {
 	public static function encode( bytes : haxe.io.Bytes, complement = true ) : String {
 		var str = new BaseCode(BYTES).encodeBytes(bytes).toString();
 		var str = new BaseCode(BYTES).encodeBytes(bytes).toString();
 		if( complement )
 		if( complement )
-			for( i in 0...(3-(bytes.length*4)%3)%3 )
+			switch (bytes.length % 3) {
+			case 1:
+				str += "==";
+			case 2:
 				str += "=";
 				str += "=";
+			default:
+			}
 		return str;
 		return str;
 	}
 	}