- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline - Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch - RTL: 351 Harbour-compatible functions - RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization - Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec) - HB_FUNC API: Full Harbour C API compatible Go bridge - Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT - Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST - Macro Compiler: Runtime AST parsing and evaluation - Debugger: TUI debugger with source display, breakpoints, stepping - FRB: Native + Pcode dual mode runtime binary - Tests: 13 packages ALL PASS Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
// Copyright (c) 2026 Charles KWON OhJun (charleskwonohjun@gmail.com)
|
|
// All rights reserved.
|
|
|
|
// Encoding/hashing functions using Go's standard library.
|
|
// HB_MD5, HB_SHA256, HB_BASE64ENCODE, HB_BASE64DECODE, HB_CRC32
|
|
|
|
package hbrtl
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"crypto/sha256"
|
|
"encoding/base64"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"five/hbrt"
|
|
"hash/crc32"
|
|
)
|
|
|
|
// HB_MD5(cString) → cHexDigest (32 chars)
|
|
func HbMD5(t *hbrt.Thread) {
|
|
t.Frame(1, 0)
|
|
defer t.EndProc()
|
|
s := t.Local(1).AsString()
|
|
h := md5.Sum([]byte(s))
|
|
t.RetString(hex.EncodeToString(h[:]))
|
|
}
|
|
|
|
// HB_SHA256(cString) → cHexDigest (64 chars)
|
|
func HbSHA256(t *hbrt.Thread) {
|
|
t.Frame(1, 0)
|
|
defer t.EndProc()
|
|
s := t.Local(1).AsString()
|
|
h := sha256.Sum256([]byte(s))
|
|
t.RetString(hex.EncodeToString(h[:]))
|
|
}
|
|
|
|
// HB_BASE64ENCODE(cString [, nLineLen]) → cBase64
|
|
func HbBase64Encode(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
s := t.Local(1).AsString()
|
|
t.RetString(base64.StdEncoding.EncodeToString([]byte(s)))
|
|
}
|
|
|
|
// HB_BASE64DECODE(cBase64) → cString
|
|
func HbBase64Decode(t *hbrt.Thread) {
|
|
t.Frame(1, 0)
|
|
defer t.EndProc()
|
|
s := t.Local(1).AsString()
|
|
data, err := base64.StdEncoding.DecodeString(s)
|
|
if err != nil {
|
|
t.RetString("")
|
|
return
|
|
}
|
|
t.RetString(string(data))
|
|
}
|
|
|
|
// HB_CRC32(cString) → nCRC32
|
|
func HbCRC32(t *hbrt.Thread) {
|
|
t.Frame(1, 0)
|
|
defer t.EndProc()
|
|
s := t.Local(1).AsString()
|
|
crc := crc32.ChecksumIEEE([]byte(s))
|
|
t.RetLong(int64(crc))
|
|
}
|
|
|
|
var _ = fmt.Sprintf // keep fmt import for future use
|