- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个用 Java 编码的 base64 编码字符串:
string s = "x8QeoAdVOAwpKHAeXIxEticayZLMx7RP_baVdSpDSLLea5TZMxRT-IX93lA05MEUzmwtOvd6WLRBluLchZz2EJSHsFfxxtPQF1VEFv4rA5w="
我正在尝试使用以下语句在 C# 中对其进行解码。
string s = "x8QeoAdVOAwpKHAeXIxEticayZLMx7RP_baVdSpDSLLea5TZMxRT-IX93lA05MEUzmwtOvd6WLRBluLchZz2EJSHsFfxxtPQF1VEFv4rA5w="
var decodedBytes = System.Convert.FromBase64String(s);
但是我得到了错误:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
我做错了什么?我可以清楚地看到没有非法字符。谁能指出我正确的方向?
更新:这是生成该字符串的 java 代码。
private static String encrypt(byte[] iv, String salt, String password, String clearText) throws Exception {
byte[] encryptedBytes = encryptDecrypt(true, iv, salt, password, clearText.getBytes("UTF-8"));
return Base64.encodeBytes(encryptedBytes, 16);
private static byte[] encryptDecrypt(boolean encrypt, byte[] iv, String salt, String password, byte[] bytesToEncryptDecrypt) throws Exception {
SecretKeySpec secretKeySpec = null;
MessageDigest digester = MessageDigest.getInstance("SHA-1");
digester.update((salt + password).getBytes("UTF-8"));
byte[] key = digester.digest();
secretKeySpec = new SecretKeySpec(key, 2, 16, "AES");
IvParameterSpec ivps = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(encrypt ? 1 : 2, secretKeySpec, ivps);
return cipher.doFinal(bytesToEncryptDecrypt, 0, bytesToEncryptDecrypt.length);
这是 Base64.class 文件(反编译)。它具有来自 Java 的编码和解码方法。
public class Base64
{
public static final int NO_OPTIONS = 0;
public static final int ENCODE = 1;
public static final int DECODE = 0;
public static final int GZIP = 2;
public static final int DONT_GUNZIP = 4;
public static final int DO_BREAK_LINES = 8;
public static final int URL_SAFE = 16;
public static final int ORDERED = 32;
private static final int MAX_LINE_LENGTH = 76;
private static final byte EQUALS_SIGN = 61;
private static final byte NEW_LINE = 10;
private static final String PREFERRED_ENCODING = "US-ASCII";
private static final byte WHITE_SPACE_ENC = -5;
private static final byte EQUALS_SIGN_ENC = -1;
private static final byte[] _STANDARD_ALPHABET = {
65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85,
86, 87, 88, 89, 90,
97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117,
118, 119, 120, 121, 122,
48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 43, 47 };
private static final byte[] _STANDARD_DECODABET = {
-9, -9, -9, -9, -9, -9, -9, -9, -9,
-5, -5,
-9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
62,
-9, -9, -9,
63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
-9, -9, -9,
-1,
-9, -9, -9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
-9, -9, -9, -9, -9, -9,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 };
private static final byte[] _URL_SAFE_ALPHABET = {
65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85,
86, 87, 88, 89, 90,
97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117,
118, 119, 120, 121, 122,
48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 45, 95 };
private static final byte[] _URL_SAFE_DECODABET = {
-9, -9, -9, -9, -9, -9, -9, -9, -9,
-5, -5,
-9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9,
-9,
62,
-9,
-9,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
-9, -9, -9,
-1,
-9, -9, -9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
-9, -9, -9, -9,
63,
-9,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 };
private static final byte[] _ORDERED_ALPHABET = {
45,
48, 49, 50, 51, 52,
53, 54, 55, 56, 57,
65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85,
86, 87, 88, 89, 90,
95,
97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117,
118, 119, 120, 121, 122 };
private static final byte[] _ORDERED_DECODABET = {
-9, -9, -9, -9, -9, -9, -9, -9, -9,
-5, -5,
-9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9,
-5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9,
-9,
0, -9,
-9,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
-9, -9, -9,
-1,
-9, -9, -9,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
-9, -9, -9, -9,
37,
-9,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 };
private static final byte[] getAlphabet(int options)
{
if ((options & 0x10) == 16)
return _URL_SAFE_ALPHABET;
if ((options & 0x20) == 32) {
return _ORDERED_ALPHABET;
}
return _STANDARD_ALPHABET;
}
private static final byte[] getDecodabet(int options)
{
if ((options & 0x10) == 16)
return _URL_SAFE_DECODABET;
if ((options & 0x20) == 32) {
return _ORDERED_DECODABET;
}
return _STANDARD_DECODABET;
}
private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options)
{
encode3to4(threeBytes, 0, numSigBytes, b4, 0, options);
return b4;
}
private static byte[] encode3to4(byte[] source, int srcOffset, int numSigBytes, byte[] destination, int destOffset, int options)
{
byte[] ALPHABET = getAlphabet(options);
int inBuff = (numSigBytes > 0 ? source[srcOffset] << 24 >>> 8 : 0) | (
numSigBytes > 1 ? source[(srcOffset + 1)] << 24 >>> 16 : 0) | (
numSigBytes > 2 ? source[(srcOffset + 2)] << 24 >>> 24 : 0);
switch (numSigBytes)
{
case 3:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[(destOffset + 1)] = ALPHABET[(inBuff >>> 12 & 0x3F)];
destination[(destOffset + 2)] = ALPHABET[(inBuff >>> 6 & 0x3F)];
destination[(destOffset + 3)] = ALPHABET[(inBuff & 0x3F)];
return destination;
case 2:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[(destOffset + 1)] = ALPHABET[(inBuff >>> 12 & 0x3F)];
destination[(destOffset + 2)] = ALPHABET[(inBuff >>> 6 & 0x3F)];
destination[(destOffset + 3)] = 61;
return destination;
case 1:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[(destOffset + 1)] = ALPHABET[(inBuff >>> 12 & 0x3F)];
destination[(destOffset + 2)] = 61;
destination[(destOffset + 3)] = 61;
return destination;
}
return destination;
}
public static void encode(ByteBuffer raw, ByteBuffer encoded)
{
byte[] raw3 = new byte[3];
byte[] enc4 = new byte[4];
while (raw.hasRemaining()) {
int rem = Math.min(3, raw.remaining());
raw.get(raw3, 0, rem);
encode3to4(enc4, raw3, rem, 0);
encoded.put(enc4);
}
}
public static void encode(ByteBuffer raw, CharBuffer encoded)
{
byte[] raw3 = new byte[3];
byte[] enc4 = new byte[4];
int i;
for (; raw.hasRemaining();
i < 4)
{
int rem = Math.min(3, raw.remaining());
raw.get(raw3, 0, rem);
encode3to4(enc4, raw3, rem, 0);
i = 0; continue;
encoded.put((char)(enc4[i] & 0xFF));
i++;
}
}
public static String encodeObject(Serializable serializableObject)
throws IOException
{
return encodeObject(serializableObject, 0);
}
public static String encodeObject(Serializable serializableObject, int options)
throws IOException
{
if (serializableObject == null) {
throw new NullPointerException("Cannot serialize a null object.");
}
ByteArrayOutputStream baos = null;
OutputStream b64os = null;
GZIPOutputStream gzos = null;
ObjectOutputStream oos = null;
try
{
baos = new ByteArrayOutputStream();
b64os = new OutputStream(baos, 0x1 | options);
if ((options & 0x2) != 0)
{
gzos = new GZIPOutputStream(b64os);
oos = new ObjectOutputStream(gzos);
}
else {
oos = new ObjectOutputStream(b64os);
}
oos.writeObject(serializableObject);
}
catch (IOException e)
{
throw e;
} finally {
try {
oos.close(); } catch (Exception localException) {
}try { gzos.close(); } catch (Exception localException1) {
}try { b64os.close(); } catch (Exception localException2) {
}try { baos.close();
} catch (Exception localException3) {
}
}
try {
return new String(baos.toByteArray(), "US-ASCII");
}
catch (UnsupportedEncodingException uue) {
}
return new String(baos.toByteArray());
}
public static String encodeBytes(byte[] source)
{
String encoded = null;
try {
encoded = encodeBytes(source, 0, source.length, 0);
} catch (IOException ex) {
if (!$assertionsDisabled) throw new AssertionError(ex.getMessage());
}
assert (encoded != null);
return encoded;
}
public static String encodeBytes(byte[] source, int options)
throws IOException
{
return encodeBytes(source, 0, source.length, options);
}
public static String encodeBytes(byte[] source, int off, int len)
{
String encoded = null;
try {
encoded = encodeBytes(source, off, len, 0);
} catch (IOException ex) {
if (!$assertionsDisabled) throw new AssertionError(ex.getMessage());
}
assert (encoded != null);
return encoded;
}
public static String encodeBytes(byte[] source, int off, int len, int options)
throws IOException
{
byte[] encoded = encodeBytesToBytes(source, off, len, options);
try
{
return new String(encoded, "US-ASCII");
} catch (UnsupportedEncodingException uue) {
}
return new String(encoded);
}
public static byte[] encodeBytesToBytes(byte[] source)
{
byte[] encoded = (byte[])null;
try {
encoded = encodeBytesToBytes(source, 0, source.length, 0);
} catch (IOException ex) {
if (!$assertionsDisabled) throw new AssertionError("IOExceptions only come from GZipping, which is turned off: " + ex.getMessage());
}
return encoded;
}
public static byte[] encodeBytesToBytes(byte[] source, int off, int len, int options)
throws IOException
{
if (source == null) {
throw new NullPointerException("Cannot serialize a null array.");
}
if (off < 0) {
throw new IllegalArgumentException("Cannot have negative offset: " + off);
}
if (len < 0) {
throw new IllegalArgumentException("Cannot have length offset: " + len);
}
if (off + len > source.length) {
throw new IllegalArgumentException(
String.format("Cannot have offset of %d and length of %d with array of length %d", new Object[] { Integer.valueOf(off), Integer.valueOf(len), Integer.valueOf(source.length) }));
}
if ((options & 0x2) != 0) {
ByteArrayOutputStream baos = null;
GZIPOutputStream gzos = null;
OutputStream b64os = null;
try
{
baos = new ByteArrayOutputStream();
b64os = new OutputStream(baos, 0x1 | options);
gzos = new GZIPOutputStream(b64os);
gzos.write(source, off, len);
gzos.close();
}
catch (IOException e)
{
throw e;
} finally {
try {
gzos.close(); } catch (Exception localException) {
}try { b64os.close(); } catch (Exception localException1) {
}try { baos.close(); } catch (Exception localException2) {
}
}
return baos.toByteArray();
}
boolean breakLines = (options & 0x8) != 0;
int encLen = len / 3 * 4 + (len % 3 > 0 ? 4 : 0);
if (breakLines) {
encLen += encLen / 76;
}
byte[] outBuff = new byte[encLen];
int d = 0;
int e = 0;
int len2 = len - 2;
int lineLength = 0;
for (; d < len2; e += 4) {
encode3to4(source, d + off, 3, outBuff, e, options);
lineLength += 4;
if ((breakLines) && (lineLength >= 76))
{
outBuff[(e + 4)] = 10;
e++;
lineLength = 0;
}
d += 3;
}
if (d < len) {
encode3to4(source, d + off, len - d, outBuff, e, options);
e += 4;
}
if (e <= outBuff.length - 1)
{
byte[] finalOut = new byte[e];
System.arraycopy(outBuff, 0, finalOut, 0, e);
return finalOut;
}
return outBuff;
}
private static int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset, int options)
{
if (source == null) {
throw new NullPointerException("Source array was null.");
}
if (destination == null) {
throw new NullPointerException("Destination array was null.");
}
if ((srcOffset < 0) || (srcOffset + 3 >= source.length)) {
throw new IllegalArgumentException(String.format(
"Source array with length %d cannot have offset of %d and still process four bytes.", new Object[] { Integer.valueOf(source.length), Integer.valueOf(srcOffset) }));
}
if ((destOffset < 0) || (destOffset + 2 >= destination.length)) {
throw new IllegalArgumentException(String.format(
"Destination array with length %d cannot have offset of %d and still store three bytes.", new Object[] { Integer.valueOf(destination.length), Integer.valueOf(destOffset) }));
}
byte[] DECODABET = getDecodabet(options);
if (source[(srcOffset + 2)] == 61)
{
int outBuff = (DECODABET[source[srcOffset]] & 0xFF) << 18 |
(DECODABET[source[(srcOffset + 1)]] & 0xFF) << 12;
destination[destOffset] = ((byte)(outBuff >>> 16));
return 1;
}
if (source[(srcOffset + 3)] == 61)
{
int outBuff = (DECODABET[source[srcOffset]] & 0xFF) << 18 |
(DECODABET[source[(srcOffset + 1)]] & 0xFF) << 12 |
(DECODABET[source[(srcOffset + 2)]] & 0xFF) << 6;
destination[destOffset] = ((byte)(outBuff >>> 16));
destination[(destOffset + 1)] = ((byte)(outBuff >>> 8));
return 2;
}
int outBuff = (DECODABET[source[srcOffset]] & 0xFF) << 18 |
(DECODABET[source[(srcOffset + 1)]] & 0xFF) << 12 |
(DECODABET[source[(srcOffset + 2)]] & 0xFF) << 6 |
DECODABET[source[(srcOffset + 3)]] & 0xFF;
destination[destOffset] = ((byte)(outBuff >> 16));
destination[(destOffset + 1)] = ((byte)(outBuff >> 8));
destination[(destOffset + 2)] = ((byte)outBuff);
return 3;
}
public static byte[] decode(byte[] source)
throws IOException
{
byte[] decoded = (byte[])null;
decoded = decode(source, 0, source.length, 0);
return decoded;
}
public static byte[] decode(byte[] source, int off, int len, int options)
throws IOException
{
if (source == null) {
throw new NullPointerException("Cannot decode null source array.");
}
if ((off < 0) || (off + len > source.length)) {
throw new IllegalArgumentException(String.format(
"Source array with length %d cannot have offset of %d and process %d bytes.", new Object[] { Integer.valueOf(source.length), Integer.valueOf(off), Integer.valueOf(len) }));
}
if (len == 0)
return new byte[0];
if (len < 4) {
throw new IllegalArgumentException(
"Base64-encoded string must have at least four characters, but length specified was " + len);
}
byte[] DECODABET = getDecodabet(options);
int len34 = len * 3 / 4;
byte[] outBuff = new byte[len34];
int outBuffPosn = 0;
byte[] b4 = new byte[4];
int b4Posn = 0;
int i = 0;
byte sbiDecode = 0;
for (i = off; i < off + len; i++)
{
sbiDecode = DECODABET[(source[i] & 0xFF)];
if (sbiDecode >= -5)
{
byte[] out;
if (sbiDecode >= -1) {
b4[(b4Posn++)] = source[i];
if (b4Posn > 3) {
outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, options);
b4Posn = 0;
if (source[i] == 61) {
break;
}
}
}
}
else
{
throw new IOException(String.format(
"Bad Base64 input character decimal %d in array position %d", new Object[] { Integer.valueOf(source[i] & 0xFF), Integer.valueOf(i) }));
}
}
out = new byte[outBuffPosn];
System.arraycopy(outBuff, 0, out, 0, outBuffPosn);
return out;
}
public static byte[] decode(String s)
throws IOException
{
return decode(s, 0);
}
public static byte[] decode(String s, int options)
throws IOException
{
if (s == null) {
throw new NullPointerException("Input string was null.");
}
try
{
bytes = s.getBytes("US-ASCII");
}
catch (UnsupportedEncodingException uee)
{
byte[] bytes;
bytes = s.getBytes();
}
byte[] bytes = decode(bytes, 0, bytes.length, options);
boolean dontGunzip = (options & 0x4) != 0;
if ((bytes != null) && (bytes.length >= 4) && (!dontGunzip))
{
int head = bytes[0] & 0xFF | bytes[1] << 8 & 0xFF00;
if (35615 == head) {
ByteArrayInputStream bais = null;
GZIPInputStream gzis = null;
ByteArrayOutputStream baos = null;
byte[] buffer = new byte[2048];
int length = 0;
try
{
baos = new ByteArrayOutputStream();
bais = new ByteArrayInputStream(bytes);
gzis = new GZIPInputStream(bais);
while ((length = gzis.read(buffer)) >= 0) {
baos.write(buffer, 0, length);
}
bytes = baos.toByteArray();
}
catch (IOException e)
{
e.printStackTrace();
try
{
baos.close(); } catch (Exception localException) {
}try { gzis.close(); } catch (Exception localException1) {
}try { bais.close(); }
catch (Exception localException2)
{
}
}
finally
{
try
{
baos.close(); } catch (Exception localException3) {
}try { gzis.close(); } catch (Exception localException4) {
}try { bais.close();
} catch (Exception localException5) {
}
}
}
}
return bytes;
}
public static Object decodeToObject(String encodedObject)
throws IOException, ClassNotFoundException
{
return decodeToObject(encodedObject, 0, null);
}
}
最佳答案
它应该像用 +
和 /
替换 Java 使用的 -
和 _
一样简单C# 使用:
string s = "Vv7JKbNHOvHxC4L89be4vNw-J0KKPkMlq4iZb_T-35u-kjYhilF_ECJAPVufv2-2_ynUORVkIPPqd1H7MC-mrWW7Fu4ZcmsHG2Q1gJOU=";
string corrected = s.Replace('-', '+').Replace('_', '/');
var decodedBytes = System.Convert.FromBase64String(corrected);
但是,您的示例字符串似乎也不正确;它有 105 个字符长,但是(因为它被填充了)长度应该是 4 的倍数。如果你从你的输入中删除尾随 =
然后这段代码有效,但我会担心它是如何得到的那里。如果它应该在那里,您需要以编程方式修剪/填充您的输入,然后仔细检查您获得的结果是否符合您的预期。
关于c# - 在 C# 中解码 Java 编码的 Base64 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13926513/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!