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"
3636itertools = " 0.14.0"
3737derivative = " 2.2.0"
3838async-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} ;
22use base64:: prelude:: * ;
33use blake2:: digest:: typenum;
44use blake2:: { Blake2b , Digest } ;
@@ -39,10 +39,16 @@ impl Fingerprint {
3939 }
4040
4141 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+ } ;
4349 match bytes. try_into ( ) {
4450 Ok ( bytes) => Ok ( Fingerprint ( bytes) ) ,
45- Err ( _ ) => bail ! ( "Fingerprint base64 length is unexpected" ) ,
51+ Err ( e ) => bail ! ( "Fingerprint bytes length is unexpected: {}" , e . len ( ) ) ,
4652 }
4753 }
4854}
You can’t perform that action at this time.
0 commit comments