Documentation ¶
Overview ¶
Package crypt implements Blowfish encryption algorithm with keys used in Nox.
Index ¶
- Constants
- func Decode(p []byte, key int) error
- func DecodeWith(c *blowfish.Cipher, p []byte) error
- func Encode(p []byte, key int) error
- func EncodeWith(c *blowfish.Cipher, p []byte) error
- func KeyForFile(path string) (int, bool)
- func NewCipher(key int) (*blowfish.Cipher, error)
- func UpdateCRC(crc uint32, p []byte) uint32
- func UpdateCRCStd(crc uint32, p []byte) uint32
- type File
- func (f *File) Align() error
- func (f *File) Buffered() int
- func (f *File) Close() error
- func (f *File) Flush() error
- func (f *File) Read(p []byte) (int, error)
- func (f *File) ReadAligned(p []byte) (int, error)
- func (f *File) Reset(d io.ReadWriteSeeker)
- func (f *File) Seek(off int64, whence int) (int64, error)
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteEmpty() (int64, error)
- func (f *File) WriteString(s string) (int, error)
- func (f *File) Written() int64
- type Reader
- func (r *Reader) Align() error
- func (r *Reader) Buffered() int
- func (r *Reader) Read(p []byte) (int, error)
- func (r *Reader) ReadAligned(p []byte) (int, error)
- func (r *Reader) ReadI16() (int16, error)
- func (r *Reader) ReadI32() (int32, error)
- func (r *Reader) ReadI64() (int64, error)
- func (r *Reader) ReadI8() (int8, error)
- func (r *Reader) ReadU16() (uint16, error)
- func (r *Reader) ReadU32() (uint32, error)
- func (r *Reader) ReadU64() (uint64, error)
- func (r *Reader) ReadU8() (byte, error)
- func (r *Reader) Reset(s io.Reader)
- func (r *Reader) Seek(off int64, whence int) (int64, error)
- type Writer
- func (w *Writer) CRC() uint32
- func (w *Writer) Close() error
- func (w *Writer) Flush() error
- func (w *Writer) Reset(d io.Writer)
- func (w *Writer) ResetCRC()
- func (w *Writer) Write(p []byte) (int, error)
- func (w *Writer) WriteBlockAt(buf [Block]byte, off int64) error
- func (w *Writer) WriteEmpty() (int64, error)
- func (w *Writer) WriteI16(v int16) error
- func (w *Writer) WriteI32(v int32) error
- func (w *Writer) WriteI32At(v int32, off int64) error
- func (w *Writer) WriteI64(v int64) error
- func (w *Writer) WriteI64At(v int64, off int64) error
- func (w *Writer) WriteI8(v int8) error
- func (w *Writer) WriteU16(v uint16) error
- func (w *Writer) WriteU32(v uint32) error
- func (w *Writer) WriteU32At(v uint32, off int64) error
- func (w *Writer) WriteU64(v uint64) error
- func (w *Writer) WriteU64At(v uint64, off int64) error
- func (w *Writer) WriteU8(v byte) error
- func (w *Writer) Written() int64
Constants ¶
const ( SoundSetBin = 5 ThingBin = 7 GameDataBin = 8 ModifierBin = 13 MonsterBin = 23 MapKey = 19 SaveKey = 27 )
Constants for known crypto keys.
const Block = blowfish.BlockSize
const ZeroCRC = uint32(0xFFFFFFFF)
ZeroCRC is an initial value for UpdateCRC function.
const ZeroCRCStd = uint32(0)
ZeroCRCStd is an initial value for UpdateCRCStd function.
Variables ¶
This section is empty.
Functions ¶
func DecodeWith ¶
DecodeWith decodes a buffer with a given cipher.
func EncodeWith ¶
EncodeWith encodes a buffer with a given cipher.
func KeyForFile ¶
KeyForFile return crypto key for a given file. If the file is unknown, it returns false.
func UpdateCRCStd ¶
UpdateCRCStd is a standard CRC update function.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func NewFile ¶
func NewFile(f io.ReadWriteSeeker, key int) (*File, error)
NewFile creates a file that support encode/decode and seek operations.
func (*File) Buffered ¶
Buffered returns a number of bytes buffered either by read or write operations.
func (*File) Flush ¶
Flush buffered data to the underlying writer. The data will be aligned to the block size.
func (*File) ReadAligned ¶
ReadAligned is a special case of aligned read used by the engine.
func (*File) Reset ¶
func (f *File) Reset(d io.ReadWriteSeeker)
Reset internal state and assign a new underlying source for the file.
func (*File) WriteEmpty ¶
WriteEmpty flushes the data (if any), which aligns it to a block size, and then writes an additional empty block without encryption.
func (*File) WriteString ¶
WriteString implements io.StringWriter.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
type Writer ¶
type Writer struct { // NoZero is a compatibility flag that forces the writer to not cleanup internal buffer with zeros. // The result is that short writes followed by Flush may expose data from previous long writes. // It is needed to keep 1:1 output from the original game engine. NoZero bool // contains filtered or unexported fields }
func (*Writer) Flush ¶
Flush buffered data to the underlying writer. The data will be aligned to the block size.
func (*Writer) WriteBlockAt ¶
WriteBlockAt encrypts and writes a block at an offset, previously returned by WriteEmpty. It requires the underlying writer to implement io.WriterAt.
func (*Writer) WriteEmpty ¶
WriteEmpty flushes the data (if any), which aligns it to a block size, and then writes an additional empty block without encryption. This block can be later written with WriteBlockAt, WriteU64At, WriteU32At, etc.
func (*Writer) WriteI32At ¶
WriteI32At encrypts and writes int32 at an offset, previously returned by WriteEmpty. It requires the underlying writer to implement io.WriterAt.
func (*Writer) WriteI64At ¶
WriteI64At encrypts and writes int64 at an offset, previously returned by WriteEmpty. It requires the underlying writer to implement io.WriterAt.
func (*Writer) WriteU32At ¶
WriteU32At encrypts and writes uint32 at an offset, previously returned by WriteEmpty. It requires the underlying writer to implement io.WriterAt.
func (*Writer) WriteU64At ¶
WriteU64At encrypts and writes uint64 at an offset, previously returned by WriteEmpty. It requires the underlying writer to implement io.WriterAt.