encode method
Encodes this ASN1Object depending on the given encodingRule
If no ASN1EncodingRule is given, ENCODING_DER will be used.
Supported encoding rules are :
Throws an UnsupportedAsn1EncodingRuleException if the given encodingRule
is not supported.
Implementation
@override
Uint8List encode(
{ASN1EncodingRule encodingRule = ASN1EncodingRule.ENCODING_DER}) {
if (encodingRule != ASN1EncodingRule.ENCODING_DER) {
throw UnsupportedAsn1EncodingRuleException(encodingRule);
}
var utc = time!.toUtc();
var year = utc.year.toString().substring(2).padLeft(2, '0');
var month = utc.month.toString().padLeft(2, '0');
var day = utc.day.toString().padLeft(2, '0');
var hour = utc.hour.toString().padLeft(2, '0');
var minute = utc.minute.toString().padLeft(2, '0');
var second = utc.second.toString().padLeft(2, '0');
// Encode string to YYMMDDhhmm[ss]Z
var utcString = '$year$month$day$hour$minute${second}Z';
valueBytes = ascii.encode(utcString);
valueByteLength = valueBytes!.length;
return super.encode();
}