File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,4 @@ indenter = "0.3.3"
36
36
itertools = " 0.14.0"
37
37
derivative = " 2.2.0"
38
38
async-lock = " 3.4.0"
39
+ hex = " 0.4.3"
Original file line number Diff line number Diff line change 1
- use anyhow:: bail;
1
+ use anyhow:: { anyhow , bail} ;
2
2
use base64:: prelude:: * ;
3
3
use blake2:: digest:: typenum;
4
4
use blake2:: { Blake2b , Digest } ;
@@ -39,10 +39,16 @@ impl Fingerprint {
39
39
}
40
40
41
41
pub fn from_base64 ( s : & str ) -> anyhow:: Result < Self > {
42
- let bytes = BASE64_STANDARD . decode ( s) ?;
42
+ let bytes = match s. len ( ) {
43
+ 24 => BASE64_STANDARD . decode ( s) ?,
44
+
45
+ // For backward compatibility. Some old version (<= v0.1.2) is using hex encoding.
46
+ 32 => hex:: decode ( s) ?,
47
+ _ => bail ! ( "Encoded fingerprint length is unexpected: {}" , s. len( ) ) ,
48
+ } ;
43
49
match bytes. try_into ( ) {
44
50
Ok ( bytes) => Ok ( Fingerprint ( bytes) ) ,
45
- Err ( _ ) => bail ! ( "Fingerprint base64 length is unexpected" ) ,
51
+ Err ( e ) => bail ! ( "Fingerprint bytes length is unexpected: {}" , e . len ( ) ) ,
46
52
}
47
53
}
48
54
}
You can’t perform that action at this time.
0 commit comments