m3u8 ts文件解密之使用go语言AES库实现加解密

本文介绍了如何使用Go语言的crypto/cipher库来实现m3u8中ts文件的AES CBC模式的加解密操作。通过官方示例和参考链接中的方法,可以对批量ts文件进行解密处理。
摘要由CSDN通过智能技术生成
// The AES block size in bytes.
const BlockSize = 16

// NewCipher creates and returns a new cipher.Block. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func NewCipher(key []byte) (cipher.Block, error)

type Block interface {
   
    // BlockSize returns the cipher's block size.
    BlockSize() int

    // Encrypt encrypts the first block in src into dst.
    // Dst and src may point at the same memory.
    Encrypt(dst, src []byte)

    // Decrypt decrypts the first block in src into dst.
    // Dst and src may point at the same memory.
    Decrypt(dst, src []byte)
}
type BlockMode interface {
   
    // BlockSize returns the mode's block size.
    BlockSize() int

    // CryptBlocks encrypts or decrypts a number of blocks. The length of
    // src must be a multiple of the block size. Dst and src may point to
    // the same memory.
    CryptBlocks(dst, src []byte)
}
func NewCBCDecrypter(b Block, iv []byte) BlockMode
func NewCBCEncrypter(b Block, iv []byte) BlockMode

官方例子
https://go-zh.org/pkg/crypto/cipher/#example_NewCBCDecrypter

package main

import (
	"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值