小编Yan*_*n39的帖子

Java SHA1哈希到base64:无符号字节?

我试图在C#Java中散列值(SHA1),然后返回base64表示.我得到2个不同的结果.

我知道这是因为Java使用有符号字节而C#没有.

C#版本:

static public string toSHA1(string toEncrypt)
{
    return toSHA1(toEncrypt, new UTF8Encoding());
}

static public string toSHA1(string toEncrypt, Encoding encoding)
{
    String salt = "fE4wd#u*d9b9kdKszgè02ep5à4qZa!éi6";
    SHA256Managed sha256hasher = new SHA256Managed();
    byte[] hashedDataBytes = sha256hasher.ComputeHash(encoding.GetBytes(toEncrypt + salt));
    return Convert.ToBase64String(hashedDataBytes);
}
Run Code Online (Sandbox Code Playgroud)

Java版本:

public static String toSHA1(String toEncrypt) {
    return toSHA1(toEncrypt, "UTF-8");
}

public static String toSHA1(String toEncrypt, String encoding) {
    String salt = "fE4wd#u*d9b9kdKszgè02ep5à4qZa!éi6";
    String res …
Run Code Online (Sandbox Code Playgroud)

c# java base64 unsigned sha1

4
推荐指数
1
解决办法
3709
查看次数

Android Studio wrong auto indent for dart

I am a newbie to Flutter and I am happy to try this great technology. And I am going to try to follow this example https://medium.com/flutterpub/flutter-auth-with-google-f3c3aa0d0ccc to do a Google Sign in

Personally, I like to separate the chains of function call line by line instead of one line. It is like below:

  _googleSignIn
        .signInSilently()
        .whenComplete(() => {
        print("Login complete");
  });
Run Code Online (Sandbox Code Playgroud)

However, when I do the auto format in Android Studio for these dart code, it give me the result …

code-formatting dart android-studio flutter

4
推荐指数
1
解决办法
1296
查看次数

Dart:解析日期时区给出 UnimplementedError

我需要在我的Flutter应用程序(来自 JSON)中解析以下格式的日期

2019-05-17T15:03:22.472+0000

根据文档,我必须使用Z来获取时区(RFC 822 格式的最后 5 个字符),所以我使用以下内容:

new DateFormat("y-M-d'T'H:m:s.SZ").parseStrict(json['startDate']);
Run Code Online (Sandbox Code Playgroud)

但它失败并出现错误:

FormatException: 2019-05-17T15:03:22.472+0000 日期解析后剩余的字符

这是另一个测试:

/// THIS WORKS
try {
    print(new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(DateTime.now()));
} catch (e) {
    print(e.toString());
}

/// THIS RETURNS `UnimplementedError` (as soon as I use a 'Z' or 'z') somewhere
try {
    print(new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(DateTime.now()));
} catch (e) {
    print(e.toString());
}
Run Code Online (Sandbox Code Playgroud)

Z执行?

timezone date date-formatting dart flutter

4
推荐指数
2
解决办法
2859
查看次数

从JQuery调用WCF服务:跨源OPTIONS请求给出错误400

我试图从JQuery调用C#WCF SOAP Web服务.

该服务托管在端口80上的IIS上,客户端从端口81上的Apache运行,两者都来自localhost.所以我陷入跨源请求.

  1. 使用Chrome,我得到预期的结果,但查看网络流量,它显示OPTIONS请求返回错误400 Bad Request,但是下一个POST请求成功: 在此输入图像描述

  2. 使用Firefox,引发错误(JavaScript警报显示null | error |).似乎POST请求未发送,因为OPTIONS请求失败: 在此输入图像描述

  3. 使用IE,一切正常,好像是来自同一个来源......我没有看到任何OPTIONS请求: 在此输入图像描述

来自界面的公开功能:

namespace Test
{
    [ServiceContract]
    public interface IMathService
    {
        [OperationContract]
        String HelloWorld();
    }
}
Run Code Online (Sandbox Code Playgroud)

服务配置(Web.config):

<services>
  <service name="Test.MathService" behaviorConfiguration="ServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:80/WCFtest/service.svc" />
      </baseAddresses>
    </host>
    <endpoint address="/soap" binding="basicHttpBinding" contract="Test.IMathService" />
    <endpoint address="/rest" binding="webHttpBinding" contract="Test.IMathService" behaviorConfiguration="WEB" />
  </service>
</services>
[...] …
Run Code Online (Sandbox Code Playgroud)

wcf jquery soap web-services cross-domain

3
推荐指数
1
解决办法
3518
查看次数

在Spring数据JPA查询中检查List参数是否为空

我有一个Spring Boot应用程序,并使用Spring Data JPA查询MySQL数据库。

我需要获取使用某些参数过滤的课程列表。

我通常使用语法,param IS NULL or (/*do something with param*/)以便在参数为null时忽略该参数。

使用简单的数据类型,我没有问题,但是当涉及对象列表时,我不知道如何检查NULL值。如何检查?3参数是否NULL在以下查询中?

@Query("SELECT DISTINCT c FROM Course c\n" +
       "WHERE c.courseDate < CURRENT_TIME\n" +
       "AND (?1 IS NULL OR (c.id NOT IN (3, 4, 5)))\n" +
       "AND (?2 IS NULL OR (c.title LIKE ?2 OR c.description LIKE ?2))\n" +
       "AND ((?3) IS NULL OR (c.category IN ?3)) ")
List<Course> getCoursesFiltered(Long courseId, String filter, List<Category> …
Run Code Online (Sandbox Code Playgroud)

sql jpa hql spring-data spring-data-jpa

3
推荐指数
3
解决办法
2443
查看次数

动画容器:RenderFlex 在底部溢出 154 像素

在设置不同的内容高度时调整动画容器的大小时遇到​​问题。

它在调整大小时抛出异常:

????????? 渲染库捕获的异常 ????????

在布局期间抛出了以下断言:

RenderFlex 在底部溢出了 154 个像素。

动画容器溢出

这是重现问题的最小示例(在我的实际应用程序中要复杂得多,但您明白了):

bool expanded;

initState() {
  super.initState();
  expanded = false;
}

void _toggleMode() {
  setState(() {
    expanded = !expanded;
  });
}

Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text("Test")),
    body: AnimatedContainer(
      height: expanded ? 230 : 70,
      duration: Duration(milliseconds: 800),
      child: Column(
        children: <Widget>[
          Expanded(
            child: PageView.builder(
              itemBuilder: (context, position) {
                return expanded
                    ? Column(
                        children: <Widget>[
                          Container(height: 40, color: Colors.blue),
                          Container(height: 40, color: Colors.blue[400]),
                          Container(height: 40, color: Colors.blue[300]),
                          Container(height: …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout flutter-animation

3
推荐指数
1
解决办法
1610
查看次数

WooCommerce - 获取购物车中不同产品的数量

WC()->cart->get_cart_contents_count()来显示 WooCommerce 购物车中的产品总数。

但是你如何获得不同产品的数量呢?

例如:

  • 3 * 产品 A
  • 2 * 产品 B

WC()->cart->get_cart_contents_count() 会返回 5。但我们想要得到 2。

wordpress woocommerce

2
推荐指数
1
解决办法
1911
查看次数

Flutter - PopupMenuItem - 如何获得价值

我有一个列表,当您单击 中的按钮时会出现该列表BottomNavigationBarItem。这是showMenu带有下面代码的列表。

但是我怎样才能得到这个列表中选择的值呢?

showMenu<int>(
  context: context,
  position: RelativeRect.fromLTRB(1000.0, 600.0, 0.0, 0.0),
  items: <PopupMenuItem<int>>[
    new PopupMenuItem<int>(child: const Text('Top 1'), value: 1),
    new PopupMenuItem<int>(child: const Text('Top 2'), value: 2),
    new PopupMenuItem<int>(child: const Text('Top 3'), value: 3),
    new PopupMenuItem<int>(child: const Text('Top 4'), value: 4),
  ],
  elevation: 8.0,
);
Run Code Online (Sandbox Code Playgroud)

widget popupmenu dart flutter

2
推荐指数
1
解决办法
1402
查看次数