hash 添加 crc32 crc64 支持
This commit is contained in:
parent
3bf4b7baa4
commit
c61f6fcc7e
@ -1,6 +1,10 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function CalcCRC32(arg1:string,arg2:number):Promise<string>;
|
||||
|
||||
export function CalcCRC64(arg1:string,arg2:number):Promise<string>;
|
||||
|
||||
export function CalcMD5(arg1:string,arg2:number):Promise<string>;
|
||||
|
||||
export function CalcSHA1(arg1:string,arg2:number):Promise<string>;
|
||||
|
@ -2,6 +2,14 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function CalcCRC32(arg1, arg2) {
|
||||
return window['go']['hash']['Support']['CalcCRC32'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CalcCRC64(arg1, arg2) {
|
||||
return window['go']['hash']['Support']['CalcCRC64'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CalcMD5(arg1, arg2) {
|
||||
return window['go']['hash']['Support']['CalcMD5'](arg1, arg2);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"crypto/sha256"
|
||||
"crypto/sha512"
|
||||
"encoding/hex"
|
||||
"hash/crc32"
|
||||
"hash/crc64"
|
||||
fileSdk "skapp/pkg/sdk/file"
|
||||
)
|
||||
|
||||
@ -17,6 +19,26 @@ func New(fileSupport *fileSdk.Support) *Support {
|
||||
return &Support{fileSupport}
|
||||
}
|
||||
|
||||
func (s *Support) CalcCRC32(path string, readSize int64) (hash string, err error) {
|
||||
h := crc32.NewIEEE()
|
||||
_, err = s.fileSupport.CopyN(h, path, readSize)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return hex.EncodeToString(h.Sum(nil)), nil
|
||||
}
|
||||
|
||||
func (s *Support) CalcCRC64(path string, readSize int64) (hash string, err error) {
|
||||
h := crc64.New(crc64.MakeTable(crc64.ECMA))
|
||||
_, err = s.fileSupport.CopyN(h, path, readSize)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return hex.EncodeToString(h.Sum(nil)), nil
|
||||
}
|
||||
|
||||
func (s *Support) CalcSHA512(path string, readSize int64) (hash string, err error) {
|
||||
h := sha512.New()
|
||||
_, err = s.fileSupport.CopyN(h, path, readSize)
|
||||
|
Loading…
Reference in New Issue
Block a user